<template>
  <div class="demo">
    <div class="demo-title">自定义交互图标</div>
    <div class="demo-content">
      <Upload
        v-model:file-list="files"
        action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
        :show-upload-list="{ showDownloadIcon: true, showRemoveIcon: true }"
        @change="handleChange"
      >
        <Button><UploadOutlined />Upload</Button>
        <template #downloadIcon>download</template>
        <template #removeIcon><StarOutlined @click="handleClick"></StarOutlined></template>
      </Upload>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue';
  import { UploadOutlined, StarOutlined } from '@ant-design/icons-vue';
  import Button from '@sscd/button';
  import Upload from '@sscd/upload';
  import type { UploadChangeParam, UploadProps } from '@sscd/upload';
  const files = ref<UploadProps['fileList']>([
    {
      uid: '1',
      name: 'xxx.png',
      status: 'done',
      response: 'Server Error 500', // custom error message to show
      url: 'http://www.baidu.com/xxx.png',
    },
    {
      uid: '2',
      name: 'yyy.png',
      status: 'done',
      url: 'http://www.baidu.com/yyy.png',
    },
    {
      uid: '3',
      name: 'zzz.png',
      status: 'error',
      response: 'Server Error 500', // custom error message to show
      url: 'http://www.baidu.com/zzz.png',
    },
  ]);
  const handleChange = ({ file, fileList }: UploadChangeParam) => {
    if (file.status !== 'uploading') {
      console.log(file, fileList);
    }
  };
  const handleClick = (e: MouseEvent) => {
    console.log(e, 'custom removeIcon event');
  };
</script>
